<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2567：篱笆</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">篱笆</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">篱笆</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                篱笆                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div style="background: white" align="left"><span style="font-size: medium"><span style="color: #200000">　　小</span><span style="color: #200000">H</span><span style="color: #200000">去美国假期实践的时候遇到了一件很有趣的事情。</span><span style="color: #200000"><br />
</span><span style="color: #200000">　　话说小</span><span style="color: #200000">H</span><span style="color: #200000">的导师家的别墅后，有一块很大的草坪。本来这是一件很和美的事情。但是，草坪的后面就是一块小森林，森林里面的兔子总是跑到草坪上来吃草。当然了，吃些草倒是没什么，但是兔子们总是将他们的排泄物留在草坪上，使得主人家的两只牧羊犬吃了它们的排泄物之后总是拉肚子。于是，小</span><span style="color: #200000">H</span><span style="color: #200000">的导师需要建一道篱笆，将后院的草坪围起来。</span><span style="color: #200000"><br />
</span><span style="color: #200000">　　篱笆销售商已经将一些标准大小的篱笆放置在草坪的边界上了。这些篱笆的长度足够覆盖整个草坪的边界，但是现在的摆放却留下了很多的空隙。然而篱笆既重又难以放置，每次放下都会毁坏一些草。因此，小</span><span style="color: #200000">H</span><span style="color: #200000">及其同伴希望找出一组篱笆的放置方法，使得所有篱笆中移动最远的一段，移动的距离最少。</span><span style="color: #200000"><br />
</span><span style="color: #200000">　　抽象来说，草坪的边界可以看做一个</span><span style="color: #200000">[0,L]</span><span style="color: #200000">的区间，既有可能是一条直线，又有可能是环形的。每块篱笆的中点为</span><span style="color: #200000">C_i</span><span style="color: #200000">，可以覆盖</span><span style="color: #200000">[C_i-r,C_i+r]</span><span style="color: #200000">的范围（环形的情况类似）。我们希望移动后的篱笆覆盖的区间包含整个边界。</span><span style="color: #200000"><br />
</span><span style="color: #200000">　　由于篱笆销售商提供的篱笆数量比较多，小</span><span style="color: #200000">H</span><span style="color: #200000">及其同伴希望知道，对于询问（</span><span style="color: #200000">X</span><span style="color: #200000">，</span><span style="color: #200000">Y</span><span style="color: #200000">），如果只是用编号为</span><span style="color: #200000">X</span><span style="color: #200000">到</span><span style="color: #200000">Y</span><span style="color: #200000">的篱笆，这个最短的移动距离是多少。这样他们就可以将多余的篱笆退回，毕竟浪费可耻嘛</span><span style="color: #200000">~~</span><span style="color: #200000">。</span></span></div></p><hr/><h3>输入格式</h3><p><div style="background: white" align="left"><span style="font-size: medium"><span style="color: #200000">　　输入文件的第一行是一个整数</span><span style="color: #200000">T</span><span style="color: #200000">，为测试数据组数。</span><span style="color: #200000"><br />
</span><span style="color: #200000">　　对于每组数据，第一行有</span><span style="color: #200000">5</span><span style="color: #200000">个整数</span><span style="color: #200000">N</span><span style="color: #200000">、</span><span style="color: #200000">L</span><span style="color: #200000">、</span><span style="color: #200000">r</span><span style="color: #200000">、</span><span style="color: #200000">Q</span><span style="color: #200000">和</span><span style="color: #200000">K</span><span style="color: #200000">，分别表示篱笆的数量、草坪边界的长度、和每段篱笆的半径，询问数，和边界的类型（</span><span style="color: #200000">K=1</span><span style="color: #200000">表示边界是一条直线，</span><span style="color: #200000">K=2</span><span style="color: #200000">表示边界是环形的）。保证有</span><span style="color: #200000">2rN&ge;L</span><span style="color: #200000">。</span><span style="color: #200000"><br />
</span><span style="color: #200000">　　接下来一行有</span><span style="color: #200000">N</span><span style="color: #200000">个整数，表示</span><span style="color: #200000">C_i</span><span style="color: #200000">的值，以升序给出。</span><span style="color: #200000"><br />
</span><span style="color: #200000">　　随后有</span><span style="color: #200000">Q</span><span style="color: #200000">行，每行</span><span style="color: #200000">2</span><span style="color: #200000">个整数</span><span style="color: #200000">X</span><span style="color: #200000">和</span><span style="color: #200000">Y</span><span style="color: #200000">，表示一组询问。保证</span><span style="color: #200000">X&le;Y</span><span style="color: #200000">且篱笆数量足够多覆盖整个边界。</span></span></div></p><hr/><h3>输出格式</h3><p><div style="background: white" align="left"><span style="font-size: medium"><span style="color: #200000">　　对于每组数据，首先在第一行中给出一个实数，表示移动最远的篱笆需要移动的距离。随后对于每组询问，在单独的一行中给出对应的结果。所有结果精确到小数点后</span><span style="color: #200000">5</span><span style="color: #200000">位。</span></span></div></p><hr/><h3>样例输入</h3><pre>2
6 8 1 2 1
1 1 2 3 4 5
1 5
3 6
6 8 1 2 2
1 1 2 3 4 5
1 5
3 6
</pre><hr/><h3>样例输出</h3><pre>2.00000
3.00000
2.00000
1.00000
1.50000
1.50000
</pre><hr/><h3>提示</h3><p><p>数据约定<br />
　　时间限制：2秒。<br />
　　0&lt;L,r&le;2^30，0&le;C_i&le;L。<br />
　　T=10。<br />
数据 1 2 3 4 5 6 7 8 9 10 <br />
K 1 1 1 1 2 2 2 2 2 2 <br />
N 1100 110000 1100 12000 110 1100 120000 1100 12000 120000 <br />
Q 0 0 1000 10000 0 0 0 1000 10000 10000</p>
<p>&nbsp;</p></p><hr/><h3>题目来源</h3><p>2012国家集训队Round 1 day3</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2567" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2567" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>